package org.to_zero.ssm.sdm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.to_zero.ssm.sdm.entity.User;
import org.to_zero.ssm.sdm.entity.vo.ResponseEntity;
import org.to_zero.ssm.sdm.service.UserService;

@RestController
@RequestMapping("/admin/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("query")
    public ResponseEntity query(User user) {
        return userService.findUserByCondition(user);
    }

    @PostMapping("update")
    public ResponseEntity update(@RequestBody User user) {
        return userService.update(user);
    }

    @DeleteMapping("delete/{id}")
    public ResponseEntity delete(@PathVariable Integer id) {
        return userService.deleteById(id);
    }

    @DeleteMapping("batchDelete/{ids}")
    public ResponseEntity batchDelete(@PathVariable Integer[] ids) {
        return userService.deleteByIds(ids);
    }
}
